Fix Hive SKEWED BY display - #2395
Conversation
| fn display_create_table_with_skewed_by() { | ||
| let column = |name| ColumnDef { | ||
| name: Ident::new(name), | ||
| data_type: DataType::String(None), | ||
| options: vec![], | ||
| }; | ||
| let stmt = CreateTableBuilder::new(ObjectName::from(vec![Ident::new("test")])) | ||
| .columns(vec![column("id")]) | ||
| .hive_distribution(HiveDistributionStyle::SKEWED { | ||
| columns: vec![column("id")], | ||
| on: vec![column("id")], | ||
| stored_as_directories: true, | ||
| }) | ||
| .build(); | ||
|
|
||
| assert_eq!( | ||
| stmt.to_string(), | ||
| "CREATE TABLE test (id STRING) SKEWED BY (id STRING) ON (id STRING) STORED AS DIRECTORIES" | ||
| ); |
There was a problem hiding this comment.
can we simplify the test to use the format here for example?
https://github.com/wenxiaojie1/datafusion-sqlparser-rs/blob/30b2a5a686135af090cf7e757070143f36cdff84/tests/sqlparser_hive.rs#L122-L125
There was a problem hiding this comment.
Thanks. I tried the verified_stmt form, but the current Hive parser rejects this syntax with Expected: end of statement, found: SKEWED. Issue #1499 explicitly notes that SKEWED BY cannot currently be parsed. I kept the explicit AST construction so the test remains scoped to the reported display bug rather than adding parser support in this PR. The focused test still passes.
There was a problem hiding this comment.
not sure I follow, if the parser doesn't accept the syntax then sounds like something more fundamental is wrong if the test was valid?
Fixes #1499.
This removes the extra closing parenthesis when formatting Hive SKEWED BY clauses and adds a display test for the constructed AST.
Checked locally: